package com.mcy.study;

import com.mcy.gles.mesh.cube.CubeActivity;
import com.mcy.gles.mesh.graphic.MeshActivity;
import com.mcy.gles.mesh.square.SquareActivity;
import com.mcy.threed.jpct.DemoActivity;
import com.mcy.threed.jpct.JpctLoadModelActivity;
import com.mcy.threed.jpct.JpctTestActivity;
import com.mcy.view.locateview.LocationViewActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class TestActivity extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		
		String[] operations = new String[]{
				"坐标控件和卫星菜单",
				"GL旋转立方体",
				"GL旋转正方形",
				"GL纹理加载",
				"JPCT3D纹理加载",
				"JPCT3D模型加载",
				"JPCT3D场景"
		};
		
		
		ListView listView = (ListView)findViewById(R.id.listView1);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(
				getBaseContext(),
				android.R.layout.simple_list_item_1,
				operations);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent intent = null;
				switch (position) {
				case 5:
					intent = new Intent(TestActivity.this,CubeActivity.class);
					break;
				case 1:
					intent = new Intent(TestActivity.this,SquareActivity.class);
					break;
				case 2:
					intent = new Intent(TestActivity.this,MeshActivity.class);
					break;
				case 3:
					intent = new Intent(TestActivity.this,JpctTestActivity.class);
					break;
				case 4:
					intent = new Intent(TestActivity.this,JpctLoadModelActivity.class);
					break;
				case 0:
					intent = new Intent(TestActivity.this,LocationViewActivity.class);
					break;
				case 6:
					intent = new Intent(TestActivity.this,DemoActivity.class);
					break;
				default:
					break;
				}
				if(intent!=null)
				    startActivity(intent);
			}
		});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.test, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
